#include<bits/stdc++.h>
using namespace std;
int main()
{
	freopen("candy.in","r",stdin);
	freopen("candy.out","w",stdout);
	long long n,l,r,r1,n1;
	cin>>n>>l>>r;
	n1=l%n;
	r1=r%n;
	if(l+n-1-n1<=r)cout<<n-1;
	else cout<<(l+r1-n1)%n; 
	fclose(stdin);
	fclose(stdout);
	return 0;
}
